$(document).ready(function() {
	dates1 = $( "#from1, #to1" ).datepicker({
			changeMonth: true,
			numberOfMonths: 1,
			onSelect: function( selectedDate ) {
				var option = this.id == "from1" ? "minDate" : "maxDate",
					instance = $( this ).data( "datepicker" ),
					date = $.datepicker.parseDate(
						instance.settings.dateFormat ||
						$.datepicker._defaults.dateFormat,
						selectedDate, instance.settings );
				dates1.not( this ).datepicker( "option", option, date );
			}
	});
	$( "#from1, #to1" ).datepicker($.datepicker.regional[ 'zh-CN'] );

	dates2 = $( "#from2, #to2" ).datepicker({
		changeMonth: true,
		numberOfMonths: 1,
		onSelect: function( selectedDate ) {
			var option = this.id == "from2" ? "minDate" : "maxDate",
				instance = $( this ).data( "datepicker" ),
				date = $.datepicker.parseDate(
					instance.settings.dateFormat ||
					$.datepicker._defaults.dateFormat,
					selectedDate, instance.settings );
			dates2.not( this ).datepicker( "option", option, date );
		}
	});
	$( "#from2, #to2" ).datepicker($.datepicker.regional[ 'zh-CN'] );
	
	$("#summaryBtn").click(function(){
		$.getJSON(getRootPath()+ "/MainMenu/profit/profitStatistics.htm", $("#summarySearchForm").serializeArray() , function(json){
			$("#returnAmount").html(json.profitSummary.returnAmount);
			$("#totalReturnAmount").html(json.profitSummary.totalReturnAmount);
			$("#memberCount").html(json.profitSummary.memberCount);
			$("#totalMemberCount").html(json.profitSummary.totalMemberCount);
			$("#profitAmount").html(json.profitSummary.profitAmount);
			$("#totalProfitAmount").html(json.profitSummary.totalProfitAmount);
		});
	});
	
	$("#profitDetailsSearchBtn").click(function(){
		$("#detailsSearchResult").html("");
		$("#pageIndex").val("1");
		$("#detailsSearchResult").load(getRootPath()+ "/MainMenu/profit/profitDetailsSearch.htm", $("#detailsSearchForm").serializeArray());
	});
	
});